﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
    public static class StringUtilities
    {
        public static string BetweenOf(this string pCadena, string pPrimeraCadena, string pSegundaCadena)            
        {
            if (string.IsNullOrEmpty(pCadena))
                return string.Empty;

            int startIndex = 0;            
            if (pCadena.Contains(pPrimeraCadena))
                startIndex = pCadena.IndexOf(pPrimeraCadena) + pPrimeraCadena.Length;

            int endIndex = pCadena.Length;
            if (pCadena.Contains(pSegundaCadena))
                endIndex = pCadena.IndexOf(pSegundaCadena, startIndex);

            if (endIndex < startIndex)
                return string.Empty;

            return pCadena.Substring(startIndex, endIndex - startIndex);
            
        }
    }
}
